<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <el-input v-model="accessTokenVal" placeholder="accessToken"></el-input>
    <el-button @click="getAccessToken" type="primary">获取accessToken</el-button>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    axios.defaults.baseURL = "http://localhost:8881/apg";
    axios.defaults.headers['Content-Type'] = 'application/json';
    new Vue({
        el: '#app',
        data: function () {
            return {
                accessTokenVal: ''
            }
        },
        methods: {
            getAccessToken() {
                axios({
                    method: 'post',
                    url: '/oauth/token?username=admin&password=admin&grant_type=password',
                    auth: {
                        username: 'apg',
                        password: 'apg_secret'
                    }
                }).then(response => {
                    this.accessTokenVal=response.data.access_token
                }).catch(error => {
                    console.log(error)
                }).finally(() => {
                })
            }
        },
        mounted() {
        }
    })
</script>
</html>